diff --git a/src/app/Mail/DegradedAccountReminder.php b/src/app/Mail/DegradedAccountReminder.php --- a/src/app/Mail/DegradedAccountReminder.php +++ b/src/app/Mail/DegradedAccountReminder.php @@ -37,15 +37,17 @@ $appName = Tenant::getConfig($this->user->tenant_id, 'app.name'); $supportUrl = Tenant::getConfig($this->user->tenant_id, 'app.support_url'); - $subject = \trans('mail.degradedaccountreminder-subject', ['site' => $appName]); + $vars = [ + 'email' => $this->wallet->owner->email, + 'name' => $this->user->name(true), + 'site' => $appName, + ]; $this->view('emails.html.degraded_account_reminder') ->text('emails.plain.degraded_account_reminder') - ->subject($subject) + ->subject(\trans('mail.degradedaccountreminder-subject', $vars)) ->with([ - 'site' => $appName, - 'subject' => $subject, - 'username' => $this->user->name(true), + 'vars' => $vars, 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id), 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id), 'dashboardUrl' => Utils::serviceUrl('/dashboard', $this->user->tenant_id), @@ -65,6 +67,8 @@ { $wallet = new Wallet(); $user = new User(); + $user->email = 'test@' . \config('app.domain'); + $wallet->owner = $user; $mail = new self($wallet, $user); diff --git a/src/app/Mail/NegativeBalance.php b/src/app/Mail/NegativeBalance.php --- a/src/app/Mail/NegativeBalance.php +++ b/src/app/Mail/NegativeBalance.php @@ -37,15 +37,17 @@ $appName = Tenant::getConfig($this->user->tenant_id, 'app.name'); $supportUrl = Tenant::getConfig($this->user->tenant_id, 'app.support_url'); - $subject = \trans('mail.negativebalance-subject', ['site' => $appName]); + $vars = [ + 'email' => $this->wallet->owner->email, + 'name' => $this->user->name(true), + 'site' => $appName, + ]; $this->view('emails.html.negative_balance') ->text('emails.plain.negative_balance') - ->subject($subject) + ->subject(\trans('mail.negativebalance-subject', $vars)) ->with([ - 'site' => $appName, - 'subject' => $subject, - 'username' => $this->user->name(true), + 'vars' => $vars, 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id), 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id), ]); @@ -64,6 +66,8 @@ { $wallet = new Wallet(); $user = new User(); + $user->email = 'test@' . \config('app.domain'); + $wallet->owner = $user; $mail = new self($wallet, $user); diff --git a/src/app/Mail/NegativeBalanceDegraded.php b/src/app/Mail/NegativeBalanceDegraded.php --- a/src/app/Mail/NegativeBalanceDegraded.php +++ b/src/app/Mail/NegativeBalanceDegraded.php @@ -38,15 +38,17 @@ $appName = Tenant::getConfig($this->user->tenant_id, 'app.name'); $supportUrl = Tenant::getConfig($this->user->tenant_id, 'app.support_url'); - $subject = \trans('mail.negativebalancedegraded-subject', ['site' => $appName]); + $vars = [ + 'email' => $this->wallet->owner->email, + 'name' => $this->user->name(true), + 'site' => $appName, + ]; $this->view('emails.html.negative_balance_degraded') ->text('emails.plain.negative_balance_degraded') - ->subject($subject) + ->subject(\trans('mail.negativebalancedegraded-subject', $vars)) ->with([ - 'site' => $appName, - 'subject' => $subject, - 'username' => $this->user->name(true), + 'vars' => $vars, 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id), 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id), ]); @@ -65,6 +67,8 @@ { $wallet = new Wallet(); $user = new User(); + $user->email = 'test@' . \config('app.domain'); + $wallet->owner = $user; $mail = new self($wallet, $user); diff --git a/src/app/Mail/NegativeBalanceReminderDegrade.php b/src/app/Mail/NegativeBalanceReminderDegrade.php --- a/src/app/Mail/NegativeBalanceReminderDegrade.php +++ b/src/app/Mail/NegativeBalanceReminderDegrade.php @@ -39,18 +39,20 @@ $supportUrl = Tenant::getConfig($this->user->tenant_id, 'app.support_url'); $threshold = WalletCheck::threshold($this->wallet, WalletCheck::THRESHOLD_DEGRADE); - $subject = \trans('mail.negativebalancereminderdegrade-subject', ['site' => $appName]); + $vars = [ + 'date' => $threshold->toDateString(), + 'email' => $this->wallet->owner->email, + 'name' => $this->user->name(true), + 'site' => $appName, + ]; $this->view('emails.html.negative_balance_reminder_degrade') ->text('emails.plain.negative_balance_reminder_degrade') - ->subject($subject) + ->subject(\trans('mail.negativebalancereminderdegrade-subject', $vars)) ->with([ - 'site' => $appName, - 'subject' => $subject, - 'username' => $this->user->name(true), + 'vars' => $vars, 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id), 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id), - 'date' => $threshold->toDateString(), ]); return $this; @@ -67,6 +69,8 @@ { $wallet = new Wallet(); $user = new User(); + $user->email = 'test@' . \config('app.domain'); + $wallet->owner = $user; $mail = new self($wallet, $user); diff --git a/src/app/Mail/PasswordExpirationReminder.php b/src/app/Mail/PasswordExpirationReminder.php --- a/src/app/Mail/PasswordExpirationReminder.php +++ b/src/app/Mail/PasswordExpirationReminder.php @@ -36,17 +36,20 @@ $appName = Tenant::getConfig($this->user->tenant_id, 'app.name'); $href = Utils::serviceUrl('profile', $this->user->tenant_id); - $params = [ - 'site' => $appName, + $vars = [ 'date' => $this->expiresOn, - 'link' => sprintf('%s', $href, $href), - 'username' => $this->user->name(true), + 'email' => $this->user->email, + 'name' => $this->user->name(true), + 'site' => $appName, ]; $this->view('emails.html.password_expiration_reminder') ->text('emails.plain.password_expiration_reminder') - ->subject(\trans('mail.passwordexpiration-subject', $params)) - ->with($params); + ->subject(\trans('mail.passwordexpiration-subject', $vars)) + ->with([ + 'vars' => $vars, + 'link' => sprintf('%s', $href, $href) + ]); return $this; } diff --git a/src/app/Mail/PasswordReset.php b/src/app/Mail/PasswordReset.php --- a/src/app/Mail/PasswordReset.php +++ b/src/app/Mail/PasswordReset.php @@ -41,15 +41,20 @@ $this->user->tenant_id ); + $vars = [ + 'email' => $this->user->email, + 'name' => $this->user->name(true), + 'site' => $appName, + ]; + $this->view('emails.html.password_reset') ->text('emails.plain.password_reset') - ->subject(\trans('mail.passwordreset-subject', ['site' => $appName])) + ->subject(\trans('mail.passwordreset-subject', $vars)) ->with([ - 'site' => $appName, + 'vars' => $vars, + 'link' => sprintf('%s', $href, $href), 'code' => $this->code->code, 'short_code' => $this->code->short_code, - 'link' => sprintf('%s', $href, $href), - 'username' => $this->user->name(true) ]); return $this; diff --git a/src/app/Mail/PaymentFailure.php b/src/app/Mail/PaymentFailure.php --- a/src/app/Mail/PaymentFailure.php +++ b/src/app/Mail/PaymentFailure.php @@ -37,15 +37,17 @@ $appName = Tenant::getConfig($this->user->tenant_id, 'app.name'); $supportUrl = Tenant::getConfig($this->user->tenant_id, 'app.support_url'); - $subject = \trans('mail.paymentfailure-subject', ['site' => $appName]); + $vars = [ + 'email' => $this->payment->wallet->owner->email, + 'name' => $this->user->name(true), + 'site' => $appName, + ]; $this->view('emails.html.payment_failure') ->text('emails.plain.payment_failure') - ->subject($subject) + ->subject(\trans('mail.paymentfailure-subject', $vars)) ->with([ - 'site' => $appName, - 'subject' => $subject, - 'username' => $this->user->name(true), + 'vars' => $vars, 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id), 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id), ]); @@ -62,11 +64,14 @@ */ public static function fakeRender(string $type = 'mail'): string { - $payment = new Payment(); $user = new User([ 'email' => 'test@' . \config('app.domain'), ]); + $payment = new Payment(); + $payment->wallet = new \App\Wallet(); + $payment->wallet->owner = $user; + $mail = new self($payment, $user); return Helper::render($mail, $type); diff --git a/src/app/Mail/PaymentMandateDisabled.php b/src/app/Mail/PaymentMandateDisabled.php --- a/src/app/Mail/PaymentMandateDisabled.php +++ b/src/app/Mail/PaymentMandateDisabled.php @@ -37,15 +37,17 @@ $appName = Tenant::getConfig($this->user->tenant_id, 'app.name'); $supportUrl = Tenant::getConfig($this->user->tenant_id, 'app.support_url'); - $subject = \trans('mail.paymentmandatedisabled-subject', ['site' => $appName]); + $vars = [ + 'email' => $this->wallet->owner->email, + 'name' => $this->user->name(true), + 'site' => $appName, + ]; $this->view('emails.html.payment_mandate_disabled') ->text('emails.plain.payment_mandate_disabled') - ->subject($subject) + ->subject(\trans('mail.paymentmandatedisabled-subject', $vars)) ->with([ - 'site' => $appName, - 'subject' => $subject, - 'username' => $this->user->name(true), + 'vars' => $vars, 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id), 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id), ]); @@ -66,6 +68,7 @@ $user = new User([ 'email' => 'test@' . \config('app.domain'), ]); + $wallet->owner = $user; $mail = new self($wallet, $user); diff --git a/src/app/Mail/PaymentSuccess.php b/src/app/Mail/PaymentSuccess.php --- a/src/app/Mail/PaymentSuccess.php +++ b/src/app/Mail/PaymentSuccess.php @@ -37,15 +37,17 @@ $appName = Tenant::getConfig($this->user->tenant_id, 'app.name'); $supportUrl = Tenant::getConfig($this->user->tenant_id, 'app.support_url'); - $subject = \trans('mail.paymentsuccess-subject', ['site' => $appName]); + $vars = [ + 'email' => $this->payment->wallet->owner->email, + 'name' => $this->user->name(true), + 'site' => $appName, + ]; $this->view('emails.html.payment_success') ->text('emails.plain.payment_success') - ->subject($subject) + ->subject(\trans('mail.paymentsuccess-subject', $vars)) ->with([ - 'site' => $appName, - 'subject' => $subject, - 'username' => $this->user->name(true), + 'vars' => $vars, 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id), 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id), ]); @@ -62,11 +64,14 @@ */ public static function fakeRender(string $type = 'html'): string { - $payment = new Payment(); $user = new User([ 'email' => 'test@' . \config('app.domain'), ]); + $payment = new Payment(); + $payment->wallet = new \App\Wallet(); + $payment->wallet->owner = $user; + $mail = new self($payment, $user); return Helper::render($mail, $type); diff --git a/src/app/Mail/SignupInvitation.php b/src/app/Mail/SignupInvitation.php --- a/src/app/Mail/SignupInvitation.php +++ b/src/app/Mail/SignupInvitation.php @@ -36,11 +36,15 @@ $href = Utils::serviceUrl('/signup/invite/' . $this->invitation->id, $this->invitation->tenant_id); + $vars = [ + 'site' => $appName, + ]; + $this->view('emails.html.signup_invitation') ->text('emails.plain.signup_invitation') - ->subject(\trans('mail.signupinvitation-subject', ['site' => $appName])) + ->subject(\trans('mail.signupinvitation-subject', $vars)) ->with([ - 'site' => $appName, + 'vars' => $vars, 'href' => $href, ]); diff --git a/src/app/Mail/SignupVerification.php b/src/app/Mail/SignupVerification.php --- a/src/app/Mail/SignupVerification.php +++ b/src/app/Mail/SignupVerification.php @@ -41,15 +41,19 @@ } $username = trim($username); + $vars = [ + 'site' => \config('app.name'), + 'name' => $username ?: 'User', + ]; + $this->view('emails.html.signup_verification') ->text('emails.plain.signup_verification') - ->subject(\trans('mail.signupverification-subject', ['site' => \config('app.name')])) + ->subject(\trans('mail.signupverification-subject', $vars)) ->with([ - 'site' => \config('app.name'), - 'username' => $username ?: 'User', + 'vars' => $vars, + 'href' => $href, 'code' => $this->code->code, 'short_code' => $this->code->short_code, - 'href' => $href, ]); return $this; diff --git a/src/app/Mail/TrialEnd.php b/src/app/Mail/TrialEnd.php --- a/src/app/Mail/TrialEnd.php +++ b/src/app/Mail/TrialEnd.php @@ -31,15 +31,16 @@ $paymentUrl = Tenant::getConfig($this->user->tenant_id, 'app.kb.payment_system'); $supportUrl = Tenant::getConfig($this->user->tenant_id, 'app.support_url'); - $subject = \trans('mail.trialend-subject', ['site' => $appName]); + $vars = [ + 'name' => $this->user->name(true), + 'site' => $appName, + ]; $this->view('emails.html.trial_end') ->text('emails.plain.trial_end') - ->subject($subject) + ->subject(\trans('mail.trialend-subject', $vars)) ->with([ - 'site' => $appName, - 'subject' => $subject, - 'username' => $this->user->name(true), + 'vars' => $vars, 'paymentUrl' => $paymentUrl, 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id), ]); diff --git a/src/resources/lang/en/mail.php b/src/resources/lang/en/mail.php --- a/src/resources/lang/en/mail.php +++ b/src/resources/lang/en/mail.php @@ -18,7 +18,7 @@ 'more-info-text' => "See :href for more information.", 'degradedaccountreminder-subject' => ":site Reminder: Your account is free", - 'degradedaccountreminder-body1' => "Thanks for sticking around, we remind you your account is a free " + 'degradedaccountreminder-body1' => "Thanks for sticking around, we remind you your :email account is a free " . "account and restricted to receiving email, and use of the web client and cockpit only.", 'degradedaccountreminder-body2' => "This leaves you with an ideal account to use for account registration with third parties " . "and password resets, notifications or even just subscriptions to newsletters and the like.", @@ -28,12 +28,12 @@ 'degradedaccountreminder-body5' => "Thank you for your consideration!", 'negativebalance-subject' => ":site Payment Required", - 'negativebalance-body' => "This is a notification to let you know that your :site account balance has run into the negative and requires your attention. " + 'negativebalance-body' => "This is a notification to let you know that your :email account balance has run into the negative and requires your attention. " . "Consider setting up an automatic payment to avoid messages like this in the future.", 'negativebalance-body-ext' => "Settle up to keep your account running:", 'negativebalancereminderdegrade-subject' => ":site Payment Reminder", - 'negativebalancereminderdegrade-body' => "It has probably skipped your attention that you are behind on paying for your :site account. " + 'negativebalancereminderdegrade-body' => "It has probably skipped your attention that you are behind on paying for your :email account. " . "Consider setting up an automatic payment to avoid messages like this in the future.", 'negativebalancereminderdegrade-body-ext' => "Settle up to keep your account running:", @@ -41,21 +41,21 @@ . "if your account balance is not settled by :date.", 'negativebalancedegraded-subject' => ":site Account Degraded", - 'negativebalancedegraded-body' => "Your :site account has been degraded for having a negative balance for too long. " + 'negativebalancedegraded-body' => "Your :email account has been degraded for having a negative balance for too long. " . "Consider setting up an automatic payment to avoid messages like this in the future.", 'negativebalancedegraded-body-ext' => "Settle up now to undegrade your account:", 'passwordreset-subject' => ":site Password Reset", - 'passwordreset-body1' => "Someone recently asked to change your :site password.", + 'passwordreset-body1' => "Someone recently asked to change your :email password.", 'passwordreset-body2' => "If this was you, use this verification code to complete the process:", 'passwordreset-body3' => "You can also click the link below:", 'passwordreset-body4' => "If you did not make such a request, you can either ignore this message or get in touch with us about this incident.", 'passwordexpiration-subject' => ":site password expires on :date", - 'passwordexpiration-body' => "Your password will expire on :date. You can change it here:", + 'passwordexpiration-body' => "Your :email account password will expire on :date. You can change it here:", 'paymentmandatedisabled-subject' => ":site Auto-payment Problem", - 'paymentmandatedisabled-body' => "Your :site account balance is negative " + 'paymentmandatedisabled-body' => "Your :email account balance is negative " . "and the configured amount for automatically topping up the balance does not cover " . "the costs of subscriptions consumed.", 'paymentmandatedisabled-body-ext' => "Charging you multiple times for the same amount in short succession " @@ -64,7 +64,7 @@ . "To resolve this issue, login to your account settings and adjust your auto-payment amount.", 'paymentfailure-subject' => ":site Payment Failed", - 'paymentfailure-body' => "Something went wrong with auto-payment for your :site account.\n" + 'paymentfailure-body' => "Something went wrong with auto-payment for your :email account.\n" . "We tried to charge you via your preferred payment method, but the charge did not go through.", 'paymentfailure-body-ext' => "In order to not cause any further issues, we suspended auto-payment for your account. " . "To resolve this issue, login to your account settings at", @@ -72,7 +72,7 @@ . "change your auto-payment settings.", 'paymentsuccess-subject' => ":site Payment Succeeded", - 'paymentsuccess-body' => "The auto-payment for your :site account went through without issues. " + 'paymentsuccess-body' => "The auto-payment for your :email account went through without issues. " . "You can check your new account balance and more details here:", 'support' => "Special circumstances? Something is wrong with a charge?\n" diff --git a/src/resources/views/emails/html/degraded_account_reminder.blade.php b/src/resources/views/emails/html/degraded_account_reminder.blade.php --- a/src/resources/views/emails/html/degraded_account_reminder.blade.php +++ b/src/resources/views/emails/html/degraded_account_reminder.blade.php @@ -4,16 +4,16 @@
-{{ __('mail.header', ['name' => $username]) }}
+{{ __('mail.header', $vars) }}
-{{ __('mail.degradedaccountreminder-body1', ['site' => $site]) }}
-{{ __('mail.degradedaccountreminder-body2', ['site' => $site]) }}
-{{ __('mail.degradedaccountreminder-body3', ['site' => $site]) }}
+{{ __('mail.degradedaccountreminder-body1', $vars) }}
+{{ __('mail.degradedaccountreminder-body2', $vars) }}
+{{ __('mail.degradedaccountreminder-body3', $vars) }}
-{{ __('mail.degradedaccountreminder-body4', ['site' => $site]) }}
-{{ __('mail.degradedaccountreminder-body5', ['site' => $site]) }}
+{{ __('mail.degradedaccountreminder-body4', $vars) }}
+{{ __('mail.degradedaccountreminder-body5', $vars) }}
-{{ __('mail.footer1') }}
-{{ __('mail.footer2', ['site' => $site]) }}
+{{ __('mail.footer1', $vars) }}
+{{ __('mail.footer2', $vars) }}